def resolution1():
    N = int(input())
    numberlist = list()
    for i in range(10**(N-1), 10**(N)-1):
        total = 0
        for j in str(i):
            total += int(j)**N
        if total == i:
            # print(total)
            numberlist.append(total)
    numberlist.sort()
    for i in numberlist:
        print(i)

def resolution2():
    result = [
        [0],
        [1],
        [2],
        [153, 370, 371, 407],
        [1634, 8208, 9474],
        [54748, 92727, 93084],
        [548834],
        [1741725, 4210818, 9800817, 9926315]
    ]
    N = int(input())
    for i in result[N]:
        print(i)

if __name__ == '__main__':
    # resolution1()
    resolution2()